#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;

void solve() {
    int n;
    cin >> n;
    vector<int> ans;
    ans.push_back(n);
    for(int i = 0; i < 30; i++) {
        if((n >> i) & 1) continue;
        int t = n | (1 << i);
        ans.push_back(t);
    }
    cout << ans.size() << endl;
    for(auto x : ans) {
        cout << x << ' ';
    }
    cout << '\n';
}

signed main() {
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}